package com.wx.mythread.uncaughtexception;


import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * 自己的UncaughtExceptionHanlder
 */
public class MyUncaughtExceptionHanlder implements Thread.UncaughtExceptionHandler {

    private String name;

    public MyUncaughtExceptionHanlder(String name){
        this.name = name;
    }

    @Override
    public void uncaughtException(Thread t, Throwable e) {
        Logger logger = Logger.getAnonymousLogger();
        logger.log(Level.WARNING, "线程异常终止了" + Thread.currentThread().getName(), e);

        System.out.println(name + "捕获了异常");
    }
}
